import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import {
    AddDataButton,
    ModDataButton,
    DelDataButton,
    SelectExcelButton,
    OpenExcelButton,
    OpenSelection,
} from '../Common/options'

export const NonFixedAssetses = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        independenceSet: {
            title: '组织机构',
            url: 'getOrgTree',
            data: { IsByUserUuid: 1 },
            type: 'TableNavTree001',
            all: true,
        },
        independence: 'organizationUuid',
        options: e => [
            <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,
            <OpenExcelButton
                key="two"
                title="批量导入"
                OptionsEvent={OptionsEvent}
                data={{
                    save: true,
                    submit: true,
                    organizationUuid: e,
                    url: 'getNonFixedAssetsesEXCELJTGJ',
                    pos: 'posNonFixedAssetsesUploadListNonFixedInfo',
                }}
            />,
            <SelectExcelButton
                key="excel1"
                title="导出数据"
                OptionsEvent={OptionsEvent}
                api={API_LIST()['getNonFixedAssetsesExcel']}
            />,
            <OpenSelection
                OptionsEvent={OptionsEvent}
                title="批量删除"
                type="primary"
                danger
                data={{
                    type: 'SelectionDelete',
                    url: 'posNonFixedAssetsesBatchRemoveListNonFixed',
                }}
            />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'FixedAssetses' },
            commonTableList.uuid,
            {
                ...commonTableList.organizationUuid,
                valueEnum: ClientData.organization,
                hideInSearch: true,
                hideInTeble: true,
            },
            { ...commonTableList.tableName, title: '资产名称' },
            {
                dataIndex: 'assetClass',
                title: '资产类别',
                valueType: 'select',
                valueEnum: { 生产类: '生产类', 办公用品类: '办公用品类' },
                width: 150,
            },
            {
                dataIndex: 'unitName',
                title: '单位名称',
                valueType: 'input',
                width: 150,
            },
            {
                dataIndex: 'projectName',
                title: '项目名称',
                valueType: 'input',
                width: 200,
            },
            {
                dataIndex: 'category',
                title: '类别',
                valueType: 'input',
                width: 200,
            },
            {
                dataIndex: 'specificationOrModel',
                title: '规格或型号',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'purchaseDate',
                title: '购置日期',
                valueType: 'Date',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'measurementUnit',
                title: '计量单位',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'quantity',
                title: '数量',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'originalValue',
                title: '原值',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'netValue',
                title: '净值',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'purchaseUnit',
                title: '购置单位',
                valueType: 'input',
                width: 200,
            },
            {
                dataIndex: 'storageLocation',
                title: '存放位置',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'assetsStatus',
                title: '状态',
                valueType: 'input',
                width: 200,
            },
            commonTableList.StartDate,
            commonTableList.EndDate,
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 120,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
